/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.actions.dispositivos;

import com.mapping.Componentes;
import com.mapping.Departamento;
import com.mapping.Dispositivo;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

/**
 *
 * @author Andres
 */
public class ListComponentes {
    public static List<Componentes> getLista(String idDisp){
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("inventarios");
        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        tx.begin();
        Dispositivo dispositivo = (Dispositivo)em.getReference(Dispositivo.class, idDisp);
        tx.commit();
        em.close();
        
        return (List<Componentes>)dispositivo.getComponentesCollection();
    }
}
